package com.minimvc.patterns.proxy
{
	import com.minimvc.interfaces.INotifier;
	import com.minimvc.interfaces.IProxy;
	import com.minimvc.patterns.observer.Notifier;
	
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;

	public class Proxy extends EventDispatcher implements IProxy
	{

		public static var NAME:String = 'Proxy';
		

		public function Proxy( proxyName:String=null, data:*=null ) 
		{
			
			this.proxyName = (proxyName != null)?proxyName:NAME; 
			if (data != null) setData(data);
		}

		/**
		 * Get the proxy name
		 */
		public function getName():String 
		{
			return proxyName;
		}		
		
		/**
		 * Set the data object
		 */
		public function setData( data:* ):void 
		{
			this.data = data;
		}
		
		/**
		 * Get the data object
		 */
		public function getData():* 
		{
			return data;
		}		

		/**
		 * Called by the Model when the Proxy is registered
		 */ 
		public function onRegister( ):void {}

		/**
		 * Called by the Model when the Proxy is removed
		 */ 
		public function onRemove( ):void {}
		
		
		override public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=true):void{
			super.addEventListener(type,listener,useCapture,priority,useWeakReference);
		}
		
		
		// the proxy name
		protected var proxyName:String;
		
		// the data object
		protected var data:*;
	}
}